<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-TAG/platForm.tld" prefix="PF"%>
<table id="dataRulesGrid">
	<thead>
		<tr>
			<th data-options="field:'ck',checkbox:true"></th>
			<th field="TITLE" data-options="sortable:true" width="20">
				名称
			</th>
			<th field="CODE" data-options="sortable:true" width="40">
				字段代码
			</th>
			<th field="SIGN" data-options="sortable:true" width="40">
				匹配类型
			</th>
			<th field="TYPE" data-options="sortable:true" width="40">
				表单类型
			</th>
		</tr>
	</thead>
</table>
<script type="text/javascript">
	var url_delActionRules = "admin/FarmFormsRulesdeleteCommit.do";//删除URL
	var url_formActionRules = "admin/FarmFormsRulesShow.do";//增加、修改、查看URL
	var url_searchActionRules = "admin/FarmFormsRulesQuery.do";//查询URL
	var title_windowRules = "查询条件管理";//功能名称
	var gridRules;//数据表格对象
	var toolBarRules = [ {
		id : 'view',
		text : '查看',
		iconCls : 'icon-tip',
		handler : viewDataRules
	}, {
		id : 'add',
		text : '新增',
		iconCls : 'icon-add',
		handler : addDataRules
	}, {
		id : 'edit',
		text : '修改',
		iconCls : 'icon-edit',
		handler : editDataRules
	}, {
		id : 'del',
		text : '删除',
		iconCls : 'icon-remove',
		handler : delDataRules
	} ];
	$(function() {
		if (!$('#domTabsId').val()) {
			$.messager.alert(MESSAGE_PLAT.PROMPT, "为获得查询定义ID--错误！", 'error');
			return;
		}
		//初始化数据表格
		gridRules = $('#dataRulesGrid').datagrid( {
			url : url_searchActionRules,
			fit : true,
			fitColumns : true,
			'toolbar' : toolBarRules,
			pagination : true,
			closable : true,
			checkOnSelect : true,
			striped : true,
			rownumbers : true,
			ctrlSelect : true,
			queryParams : {
				ids : $('#domTabsId').val()
			}
		});
	});
	//查看
	function viewDataRules() {
		var selectedArray = $(gridRules).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionRules + '?pageset.pageType='
					+ PAGETYPE.VIEW + '&ids=' + selectedArray[0].ID;
			$.farm.openWindow( {
				id : 'winRules',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '浏览'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//新增
	function addDataRules() {
		var url = url_formActionRules + '?ids=' + $('#domTabsId').val()
				+ '&pageset.pageType=' + PAGETYPE.ADD;
		$.farm.openWindow( {
			id : 'winRules',
			width : 600,
			height : 300,
			modal : true,
			url : url,
			title : '新增'
		});
	}
	//修改
	function editDataRules() {
		var selectedArray = $(gridRules).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionRules + '?pageset.pageType='
					+ PAGETYPE.EDIT + '&ids=' + selectedArray[0].ID;
			$.farm.openWindow( {
				id : 'winRules',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '修改'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//删除
	function delDataRules() {
		var selectedArray = $(gridRules).datagrid('getSelections');
		if (selectedArray.length > 0) {
			// 有数据执行操作
			var str = selectedArray.length + MESSAGE_PLAT.SUCCESS_DEL_NEXT_IS;
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$(gridRules).datagrid('loading');
					$.post(url_delActionRules + '?ids='
							+ $.farm.getCheckedIds(gridRules, 'ID'), {},
							function(flag) {
								$(gridRules).datagrid('loaded');
								if (flag.pageset.commitType == 0) {
									$(gridRules).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
</script>